#include"cross.h"
#include<stdio.h>
#include<malloc.h>


Cross* mkCross(){
	Cross* cross=(Cross*)malloc(sizeof(Cross));
	cross->top = -1;
	cross->crst = (Stack*) malloc(sizeof(Stack)*100);
	return cross;
}

int isempty(Cross* cross){
	if(cross->top < 0){
		return TRUE;
	}else{
		return FALSE;
	}
}
int isfull(Cross* cross){
	if(cross->top < 100){
		return FALSE;
    }
	else{
		printf("Full!i\n");
		return TRUE;
	}
}

int push(Cross* cross, int x, int y, int way){
	if(!isfull(cross)){
		cross->crst[++(cross->top)].x=x;
		cross->crst[cross->top].y=y;
		cross->crst[cross->top].way=way;
		return 1;
	}
	else{
		return -1;
	}
}

int pop(Cross* cross, int* x, int* y){
	if(!isempty(cross)){
		*x = cross->crst[cross->top].x;	
		*y = cross->crst[cross->top].y;
		return cross->crst[cross->top--].way;
	}else{
		return -1;
	}
}

void delCross(Cross* cross){
	free(cross->crst);
	free(cross);
}
